#ifndef TRACKING_THREAD_HXX
#define TRACKING_THREAD_HXX
#include <QThread>

#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/tracking.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/tracking.hpp>
#include <opencv2/core/ocl.hpp>

#include <yolo_v2_class.hpp>

class Sequence;
class FramePool;

enum TrackingStatus
{
	TR_STATUS_FREE,
	TR_STATUS_RUNNING,
	TR_STATUS_STOPPED
};

class YOLOTrackingThread : public QThread
{
	Q_OBJECT
public:
    YOLOTrackingThread();
    ~YOLOTrackingThread();

	void initialize();

	void run() override;

	void pause();
	void resume();
	void slow();
	void fast();
	void next();
	void stop();

    inline void setModel(Sequence* model) { _model = model; }

	inline void setInputFramePool(FramePool* pool) { _inputPool = pool; }
	inline void setOutputFramePool(FramePool* pool) { _outputPool = pool; }

	void startTrack();
	void stopTrack();

	void setTrackerType(const char* trackerType) { strcpy(_trackerType, trackerType); }

	inline bool isPaused() { return _pauseFlag; }

	inline TrackingStatus getTrackingStatus() { return _status; }
private:
    Sequence* _model;

	FramePool* _inputPool;
	FramePool* _outputPool;

	char* _frameBuffer;

	bool _stopTrackFlag;
	bool _trackingFlag;
	
	bool _pauseFlag;
	bool _slowFlag;
	bool _trackerInitedFlag;
	bool _nextFlag;
	bool _stopFlag;

	char _trackerType[256];

    Detector* _detector;

	TrackingStatus _status;
};

#endif
